#ifndef H_BWLISTDIALOG
#define H_BWLISTDIALOG
#include "precompiled.h"
#include "ui_bwlistdialog.h"
#include "engine/engineheader.h"
namespace weo
{
    namespace ui
    {
        class BWListValidator : public QValidator
        {
        private:
            mutable unsigned int m_Index;
            std::vector<std::string> m_Values;
            unsigned int m_StartChar[256];
        public:
            void setValues(const std::vector<std::string>& values);
            const unsigned int Index() const {return m_Index;};
            QValidator::State validate ( QString & input, int & pos ) const;
            BWListValidator(QObject *parent = 0) : QValidator (parent)
            {
            };
        };
        class BWListDialog : public QDialog, protected Ui_BWListDialog
        {
            Q_OBJECT
        private:
            std::map<unsigned int, bool> m_ItemsMap;
            std::map<unsigned int, bool> m_AllItemsMap;
            std::map<QListWidgetItem *,unsigned int> m_ItemIdMap;
            std::map<std::string,QListWidgetItem *> m_ItemNameMap;
            static std::set<unsigned int> s_Whitelist;
            static std::set<unsigned int> s_Blacklist;
            void setupList();
            BWListValidator *m_SearchValidator;
            private slots:
                void on_ItemsList_itemDoubleClicked ( QListWidgetItem * item );  
                void on_SearchLineEdit_textEdited( const QString & text );
        public:
            void setItems(const std::vector<std::vector<const weo::engine::item::Item*>>& items);
            static std::set<unsigned int> getBlacklist() {return s_Blacklist;};
            static std::set<unsigned int> getWhitelist() {return s_Whitelist;};
            BWListDialog(QWidget* parent = 0, Qt::WFlags flags = 0);
            static void loadXmlBWlist();
            static void saveXmlBWlist();
            void CleanUp(){ delete m_SearchValidator; };
        };
    };
};
#endif